#include <iostream>
#include "swap.h"

using namespace std;
void sort_arr(int *p, int len);
void print_arr(int *p, int len);

void print_std(const struct Student *s);

void set_teacher_student(struct Teacher *t, int t_len);
void print_teachers(const struct Teacher *t, int t_len);

struct Student
{
    string name;
    int score;
};

struct Teacher
{
    string name;
    struct Student students[5];
};

int main()
{
    system("chcp 65001");

    struct Teacher t[3];
    set_teacher_student(t, 3);
    print_teachers(t, 3);

    return 0;
}

void sort_arr(int *p, int len)
{
    cout << p[0] << endl;
    for (size_t i = 0; i < len; i++)
    {
        for (size_t j = i + 1; j < len - i - 1; j++)
        {
            /* code */
            if (p[j] > p[j + 1])
            {
                int temp = p[j + 1];
                p[j + 1] = p[j];
                p[j] = temp;
            }
        }
    }
};

void print_arr(int *p, int len)
{
    cout << "-----------------------" << endl;
    for (size_t i = 0; i < len; i++)
    {
        cout << *p << endl;
        p++;
    }
}

void set_teacher_student(struct Teacher *t, int size)
{
    for (size_t i = 0; i < size; i++)
    {
        string name_seed = "ABCDEFG";
        t[i].name = "Teacher_";
        t[i].name += name_seed[i];
        for (size_t j = 0; j < 5; j++)
        {
            t[i].students[j].name = "Student_";
            t[i].students[j].name += name_seed[j];
            int r = rand() % 100 + 1;
            t[i].students[j].score = r;
        }
    }
}

void print_teachers(const struct Teacher *t, int t_len)
{
    for (size_t i = 0; i < t_len; i++)
    {
        cout << "老师" << i << "姓名： " << t[i].name << endl;
        for (size_t j = 0; j < 5; j++)
        {
            cout << "   学生" << j + 1 << "姓名： " << t[i].students[j].name<< "成绩： " << t[i].students[j].score << endl;
        }
    }
}